/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.property.repository;

import me.zhengjie.modules.property.domain.Property1;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.sql.Date;
import java.util.List;
import java.util.Map;

/**
* @website https://el-admin.vip
* @author yyj
* @date 2021-10-01
**/
public interface Property1Repository extends JpaRepository<Property1, Integer>, JpaSpecificationExecutor<Property1> {


    @Query(value="SELECT sum(price) from property where left(create_time,10) between ?1 and ?1",nativeQuery=true)
    long querySum(Date dateOne);

    @Query(value="SELECT count(*) from property where left(create_time,7) = ?1",nativeQuery=true)
    long number(String dateOne);

    @Query(value="SELECT count(*),left(create_time,7) from property where left(create_time,7) in (?1) group by left(create_time,7)",nativeQuery=true)
    List<Map<Object,Object>> number1(List<String> date);

}